Skip to content

fix(classifier): avoid forcing unsupported temperature - #2

Merged
czottmann merged 1 commit into
czottmann:mainfrom
tank-bohr:fix/classifier-provider-errors
Jul 18, 2026
Merged

fix(classifier): avoid forcing unsupported temperature#2
czottmann merged 1 commit into
czottmann:mainfrom
tank-bohr:fix/classifier-provider-errors

Conversation

@tank-bohr

Copy link
Copy Markdown
Contributor

Problem

Classifier calls currently force temperature: 0. Providers that do not support the parameter, including OpenAI Codex, reject the request before classification:

Unsupported parameter: temperature

pi-ai represents this as an assistant response with stopReason: "error". The classifier then treats the empty response body as malformed JSON, retries the same request, and reports a misleading invalid-JSON failure.

Changes

  • Use the provider's default temperature unless a caller explicitly configures one.
  • Fail closed immediately on provider-reported completion errors.
  • Preserve the provider error message in classifier I/O logs and the user-facing block reason.
  • Update classifier-flow and observability documentation.
  • Cover default and explicit temperature behavior plus provider-reported errors.

Verification

  • npm run check
  • npm test (65 tests)
  • npm pack --dry-run
  • Live classifier call through openai-codex/gpt-5.6-sol with no temperature override returned a valid allow decision.

@czottmann czottmann left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, good find! Nonetheless, I have to ask for a few changes.

  • P1 — fail closed based on stopReason, not the error text (extensions/auto-mode/classifier.ts:177-200): an error response with errorMessage: "" is treated as non-error. If it also contains valid allow JSON, classifyWithRetry returns allow. I reproduced that case. Branch on response.stopReason === "error" and use response.errorMessage || <fallback> only for the displayed reason. Add a regression test for the empty-message case.

  • P1 — rebase and resolve the conflicts with current main: this branch conflicts with the ccusage observability work in classifier.ts, types.ts, tests, and docs/observability-logging.md. Preserve current main's model, timestamp, and usage fields while adding errorMessage?; taking either side wholesale loses useful observability data.

  • P3 — strengthen the temperature regression test (tests/auto-mode.test.ts:396-424): reading .temperature does not distinguish an omitted property from { temperature: undefined }. Assert Object.hasOwn(callOptions, "temperature") === false for the default path.

PR-head validation passed: npm run check, 65 tests, npm pack --dry-run, and git diff --check. The post-conflict merged result still needs the same validation.

Let classifier providers use their default temperature unless a caller explicitly supplies one. Some providers, including OpenAI Codex, reject the parameter entirely.

Treat provider-reported completion errors as classifier failures instead of retrying them as malformed JSON, and retain the provider message in classifier I/O logs.
@tank-bohr
tank-bohr force-pushed the fix/classifier-provider-errors branch from d425d00 to 6d73d98 Compare July 18, 2026 06:59
@tank-bohr

Copy link
Copy Markdown
Contributor Author

@czottmann Done ✔️

@czottmann
czottmann merged commit 07c5b43 into czottmann:main Jul 18, 2026
@czottmann

Copy link
Copy Markdown
Owner

Thanks, @tank-bohr! Had to manually merge your contributions as main was further along already and a number of changes had been made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants